/**
 * Person class.
 *
 * @author	David Alvarez Lopez
 * @date	05-Nov-2006
 *
 */

package com.dekaru.misc.person;

public class Person {
	
	private String name; 	//The name of the person
	private int age;		//The age of the person
	private boolean sex;	//true: male, false: female
	
    // ==================
    // CLASS CONSTRUCTORS 
    // ==================
	
	/** 
	*A constructor that sets the name and age to null.
	**/	
	public Person() {
		
		name = "";
		age = 0;	
	}
	/** 
	*A constructor that sets the name to the parameters received.
	*
	*@Param		name	the name of the Person object.
	**/	
	public Person(String name) {
		
		this.name = name;
	}
	public Person(int age) {
		
		this.age = age;
	}
	public Person(boolean sex) {
		
		this.sex = sex;
	}
	/** 
	*A constructor that sets the name and age to the parameters received.
	*
	*@Param		name	the name of the Person object.
	*@Param		age		the age of the Person object.
	**/	
	public Person(String name, int age) {
		
		this.name = name;
		this.age = age;
	}
	/** 
	*A constructor that sets the name and sex to the parameters received.
	*
	*@Param		name	the name of the Person object.
	*@Param		sex		the sex of the Person object, true if male, false if female
	**/	
	public Person(String name, boolean sex) {
		
		this.name = name;
		this.sex = sex;
	}
	/** 
	*A constructor that sets the name and age to the parameters received.
	*
	*@Param		age	the age of the Person object.
	*@Param		sex		the sex of the Person object, true if male, false if female
	**/	
	public Person(int age, boolean sex) {
		
		this.age = age;
		this.sex = sex;
	}
	/** 
	* A constructor that sets the name, age and sex to the parameters received.
	*
	* @Param		name	the name of the Person object.
	* @Param		age		the age of the Person object.
	* @Param		sex		the sex of the Person object, true if male, false if female
	**/	
	public Person(String name, int age, boolean sex) {
		
		this.name = name;
		this.age = age;
		this.sex = sex;
	}
	
    // ===================
    // GETTERS, SETTERS... 
    // ===================
	
	/** 
	*A method that returns the sex.
	*
	*@return	true if male, false if female
	**/	
	public boolean getSex() {
		return sex;
	}
	/** 
	*A method sets the sex of the invoking object by the parameter given..
	*
	*@param sex	an integer representing the sex. true if male, false if female. 
	**/	

	public void setSex(boolean sex) {
		this.sex = sex;
	}

	/** 
	*A method that returns the name.
	*
	*@return	name	the name of the invoking object
	**/	
	public String getName() {
		
		return name;	
	}
	/** 
	*A method that returns the age.
	*
	*@return	age		the age of the invoking object
	**/	
	public int getAge() {
		
		return age;	
	}
	/** 
	*A method sets the name of the invoking object by the parameter given..
	*
	*@param		name	the new name.
	**/	
	public void setName(String name) {
		
		this.name = name;	
	}
	/** 
	*A method sets the age of the invoking object by the parameter given..
	*
	*@param		age		the new age.
	**/	
	public void setAge(int age) {
		
		this.age = age;	
	}
	
    // ====================
    // OTHER USEFUL METHODS 
    // ====================
	
	/** 
	*A method sets the name of the invoking object by the parameter given..
	*
	*@param		obj		the Person object that is going to be compared.
	*@return	a Boolean TRUE if the object invoking object is the same as the parameter givne.
	**/	
	public boolean equals(Person obj) {
	
		return ((this.getName().equals(obj.getName())) &&
				(this.getAge()==obj.getAge()) &&
				(this.getSex()==obj.getSex()));
	}
	
	/** 
	*A method prepares a String chain describing the object..
	*
	*@return	a String that is the chain of the object's contents..
	**/	
	public String toString() {
	
		return ( this.getName() + " is a " + this.getSex() + " and is " + this.getAge() + "years old.");
	}
}